package com.example.imtoken.room.dao

import androidx.room.*
import com.example.imtoken.room.schema.TransactionRecordSchema

@Dao
interface TransactionRecordDao {

    @Insert
    fun insert(transactionRecordSchema: TransactionRecordSchema): Long

    /**
     * 根据交易状态查询
     * @param state Int
     * @return MutableList<TransactionRecordSchema>?
     */
    @Query("SELECT * FROM transaction_record WHERE type = :type")
    fun findTypeData(type: Int): MutableList<TransactionRecordSchema>?

    /**
     * 查询全部
     * @return MutableList<TransactionRecordSchema>?
     */
    @Query("SELECT * FROM transaction_record")
    fun findAllData(): MutableList<TransactionRecordSchema>?

    /**
     * 根据id查询
     * @param id Int
     * @return TransactionRecordSchema?
     */
    @Query("SELECT * FROM transaction_record WHERE id = :id")
    fun findByIdData(id: Int): TransactionRecordSchema?

    @Update
    fun updateData(transactionRecordSchema: TransactionRecordSchema): Int

    @Query("DELETE FROM transaction_record")
    fun delete(): Int

}